package createmailbox;

## This file is part of the Simplemail project.
#  Copyright (c) 2008 the Simplemail Team (see authors).
# 
#  For the full copyright and license information, please view the COPYING
#  file that was distributed with this source code. You can also view the
#  COPYING file online at http://unixforum.org.ua/misc/COPYING.txt
# 
#  @copyright  (c) the authors
#  @author     Dmitriy Shilenko <rtyug@ukr.net>
#  @license    GPLv2 http://unixforum.org.ua/misc/COPYING.txt
#  @package    Panel Mailbox
#  @version    $Id: $

use strict;
use CGI::Carp qw(fatalsToBrowser);
use base 'func';

sub new {
    my $self = shift->SUPER::new(@_);
    $self->dbi_connect if $self->can("dbi_connect");
    return $self;
}

sub return_create_mailbox {
    my $self = shift;

    my $sth = $self->{dbh}->prepare(
        'SELECT domain FROM domain WHERE idnane = ?
                             '
    );
    $sth->execute( $self->{session}->{user} );
    my $rows;
    push @{$rows}, $_ while $_ = $sth->fetchrow_hashref();
    $sth->finish();

    if ( !$rows ) {
        $self->{he}->{NO_DOMAIN} = 1;
    }
    else {
        $self->{he}->{ROWS} = $rows;
    }

    return $self;
}

sub templ_hash_mailbox {
    my $self = shift;

    $self->{session}->{filet} = 'create-mailbox';
    $self->SUPER::templ_hash(@_);
}

sub DESTROY {
    my $self = shift;
    $self->SUPER::DESTROY if $self->can("SUPER::DESTROY");
}

1;
